﻿using System;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Reflection;
namespace Data
{
	 	//DrawWin
		public class DrawWin
	{	
		/// <summary>
        /// 主键
        /// </summary>
        private readonly string primaryKey= "Id";
		/// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long Add(Model.DrawWin model)
        {
            return new DataAccess().Add<Model.DrawWin>(model, primaryKey);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(Model.DrawWin model)
        {
            return new DataAccess().Update<Model.DrawWin>(model, primaryKey);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool Delete(long Id)
        {
            return new DataAccess().Delete<Model.DrawWin>(Id, primaryKey);
        }
        /// <summary>
        /// 单条
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Model.DrawWin GetModel(long Id)
        {
            return new DataAccess().Get<Model.DrawWin>(Id, primaryKey);
        }
        public Model.DrawWin GetModelByDrawWinid(long DrawWinid)
        {
            return new DataAccess().Get<Model.DrawWin>(DrawWinid, "Id");
        }
        public Model.DrawWin GetModelBysql(string sql)
        {
            return new DataAccess().Get<Model.DrawWin>(sql);
        }
        /// <summary>
        /// 总数据数
        /// </summary>
        /// <returns></returns>
        public int GetAll_Count()
        {
            return new DataAccess().GetCount<Model.DrawWin>(primaryKey);
        }
        /// <summary>
        /// 抽取分页数据
        /// </summary>
        public List<Model.DrawWin> GetPageList_Where(int PageIndex, int PageSize, out int totalCount)
        {          
            totalCount = new DataAccess().GetCount<Model.DrawWin>(primaryKey, "");
            return new DataAccess().GetPage_List<Model.DrawWin>(PageIndex, PageSize, primaryKey, primaryKey+" asc", "");
        }
        public DataTable GetPageDT_Where(int PageIndex, int PageSize, string strWhere, out int totalCount)
        { 
            totalCount = new DataAccess().GetCount<Model.DrawWin>(primaryKey, strWhere);
            return ConvertHelper<Model.DrawWin>.ConvertToDT(new DataAccess().GetPage_List<Model.DrawWin>(PageIndex, PageSize, primaryKey, primaryKey + " desc", strWhere));
        } 
        /// <summary>
        /// 批删
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public int Drop(string Ids)
        {
            return new DataAccess().Drop<Model.DrawWin>(Ids, primaryKey);
        }
	}
}